<?php
// *** Tangra (Application Framework and Tools for PHP)
// $Id$
//

require_once(TANGRA_MAIN_DIR.'db/db_config.class.php');
require_once('dbal_conn.class.php');


class Site_DBC extends DBAL_Conn {

	function __construct(DB_Config $db_config) {
		parent::__construct($db_config->get_db_dsn());

		// default is autocommit OFF. If you need autocommit ON (+ persistent connection) please use page's->get_dbc_pnt()
		$autocommit = $db_config->get_db_autocommit() !== NULL ? $db_config->get_db_autocommit() : 0; 
		$this->execute('SET AUTOCOMMIT='.$autocommit);
		$this->set_autocommit($autocommit);

		$this->execute("SET NAMES '".($db_config->get_db_default_charset() ? $db_config->get_db_default_charset() : 'utf8')."'");
		$this->execute('SET CHARACTER SET '.($db_config->get_db_default_charset() ? $db_config->get_db_default_charset() : 'utf8'));
	}
}


